#ifndef MY_CGAME_H
#define MY_CGAME_H


#include <mzfc_inc.h>
#include <acc_api.h>
#include <MotorVibrate.h>

#include "..\YiEDB\YiEDB.h"

#include "CScript.h"
#include "CScene.h"



#define X		10
#define XX		18
#define Y		9
#define	YY		18
#define DXY		5



#define SETTING_SOUND	0
#define SETTING_VIBRATE	1
#define SETTING_PW1		2
#define SETTING_PW2		3
#define SETTING_PW3		4

#define UN_DEFINE		0xFFFFFFFF

#define VIBRATE_ON_TIME	80
#define VIBRATE_TIMER	1

#define MAX_PLAYER_NAME	16
#define MAX_SCORE_RECORD_COUNT	10
#define MAX_TIME_RECORD_COUNT	10



struct GAME_SETTING
{
	bool	bSound;
	bool	bVibrate;
	DWORD	dwPassword1;
	DWORD	dwPassword2;
	DWORD	dwPassword3;
	DWORD	dwPassword4;

	//
	bool	bCheatOn;
	DWORD	dwCheatHammer;
	DWORD	dwCheatLevel;
	DWORD	dwCheatMoney;
	bool	dwCheatWings;

};



struct GAME_DATA
{
};



class CGame
{
public:
	CGame()
	{
		wszInputChar = 0;
		m_bStarLogic = false;

	}

	DWORD	CalPassword( DWORD dwKey );
	bool	CheckPassword( DWORD dwKey );
	void	DestroyGame();	
	HRESULT	InitGame( CMzWndEx *pWnd );
	void	LoadAllSettings();
	inline	GAME_SETTING*	GetSetting()	{ return &m_Setting; };
	void	MzDefWndProc( UINT message, WPARAM wParam, LPARAM lParam );	// msg
	void	OnLButtonDown( UINT fwKeys, int xPos, int yPos );
	void	OnMouseMove( UINT fwKeys, int xPos, int yPos );
	void	OnMzCommand( WPARAM wParam, LPARAM lParam );				// cmd
	void	RunGame();
	void	SetSoundEnable( bool bEnable, bool bWrite );
	void	SetVibrateEnable( bool bEnable, bool bWrite );
	void	SaveSetting();
	void	Vibrate();
	void	SaveBossTime( DWORD dwBossTime, LPWSTR lpwsPlayerName );
	void	SaveHeightScore( DWORD dwHeightScore );
	void	SaveHeightScore( DWORD dwHeightScore, LPWSTR lpwsPlayerName );
	DWORD	LoadHeightScore( bool bMaxScore = true );
	DWORD	LoadBossTime( bool bMinTime = true );
	void	OpenDataFile();

	inline
	WCHAR GetInputBuffer()
	{
		WCHAR wszTemp = wszInputChar;
		wszInputChar = 0;
		return wszTemp;

	}

	GAME_SETTING	m_Setting;
	Yi::YiEDB		g_EDB;

	WCHAR			wszInputChar;

	bool			m_bStarLogic;

protected:
	void	DisplayFrameRate();
	void	LoadResource();
	DWORD	m_dwFramesLast;
	DWORD	m_dwFrames;
	DWORD	m_dwFrameCount;
	DWORD	m_dwFrameTime;

	void	LoadIEMI();
	char	m_IEMI[15];

	CMzWndEx*	m_pWnd;

protected:
	CScene*		m_pScene;

};



extern CGame		g_CGame;



#endif